classdef TransBetter < FilterFather
    properties
    end
    
    methods
        function this = TransBetter(guiData)
            this.calculateFilter(guiData);
            minEdge = min([guiData.Fp guiData.Fa])*2*pi;
            maxEdge = max([guiData.Fp guiData.Fa])*2*pi;
            this.calcData([minEdge maxEdge]);
        end
        
        function calculateFilter(obj,guiData)
            
            Aa = guiData.Aa;
            obj.Approximation = 'Buby';
            Wp = guiData.Fp*2*pi;
            Wa = guiData.Fa*2*pi;
            [Wp Wa] = obj.adjustBand(Wp,Wa);
            obj.FilterType = guiData.filterType;
            obj.DesnormValue = guiData.DenormVal;
            obj.DesnormType = guiData.DenormType;
            obj.normalization(Wp,Wa);            
            bessel = Bessel(guiData);
            guiData.fixOrder = true;
            guiData.order = bessel.Order;
            butter = Butterworth(guiData);
            obj.Order = guiData.order;
            butter.NormalizedPoles = butter.NormalizedPoles(imag(butter.NormalizedPoles) >= 0);
            bessel.NormalizedPoles = bessel.NormalizedPoles(imag(bessel.NormalizedPoles) >= 0);
            [poles1 poles2] = obj.sortpoles(butter.NormalizedPoles, bessel.NormalizedPoles);
            poles1 = [poles1; conj(poles1(imag(poles1) > 0))];
            poles2 = [poles2; conj(poles2(imag(poles2) > 0))];
            guiData.Trans = 1 - guiData.Trans;
            obj.Poles = poles1*guiData.Trans + poles2*(1-guiData.Trans);
            obj.Zeros = [];
            obj.K = abs(prod(obj.Poles));
            obj.frecDesnorm(Aa);
            obj.K = abs(prod(obj.Poles));	
            obj.desnormalization();
            obj.TransferFunction = obj.TransferFunction*10^(guiData.gain/20);
        
        end
    end
end